package cn.lanqiao.service.impl;

import cn.lanqiao.dao.AccountDao;
import cn.lanqiao.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service("service")
@Transactional
public class AccountServiceImpl implements AccountService {
    @Autowired
    private AccountDao dao;

    @Transactional(isolation = Isolation.DEFAULT,propagation = Propagation.REQUIRED, readOnly = false,timeout = -1)
    @Override
    public void Transfer(String inMan, String outMan, Integer money) {
        // 从转账者的账户减去响应的金额
        dao.updateBalance(outMan,-money);
        int i = 1/0;
        // 将收款者的账户金额增加
        dao.updateBalance(inMan,money);
    }
}
